/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package escr.persistencia;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Aditardo
 */
@Entity
@Table(name = "especialidad")
@NamedQueries({@NamedQuery(name = "Especialidad.findByEspCod", query = "SELECT e FROM Especialidad e WHERE e.espCod = :espCod"), @NamedQuery(name = "Especialidad.findByEspNombre", query = "SELECT e FROM Especialidad e WHERE e.espNombre = :espNombre")})
public class Especialidad implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ESP_COD", nullable = false)
    private Integer espCod;
    @Column(name = "ESP_NOMBRE", nullable = false)
    private String espNombre;
    @OneToMany(mappedBy = "espCod")
    private Collection<ProEspe> proEspeCollection;

    public Especialidad() {
    }

    public Especialidad(Integer espCod) {
        this.espCod = espCod;
    }

    public Especialidad(Integer espCod, String espNombre) {
        this.espCod = espCod;
        this.espNombre = espNombre;
    }

    public Integer getEspCod() {
        return espCod;
    }

    public void setEspCod(Integer espCod) {
        this.espCod = espCod;
    }

    public String getEspNombre() {
        return espNombre;
    }

    public void setEspNombre(String espNombre) {
        this.espNombre = espNombre;
    }

    public Collection<ProEspe> getProEspeCollection() {
        return proEspeCollection;
    }

    public void setProEspeCollection(Collection<ProEspe> proEspeCollection) {
        this.proEspeCollection = proEspeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (espCod != null ? espCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Especialidad)) {
            return false;
        }
        Especialidad other = (Especialidad) object;
        if ((this.espCod == null && other.espCod != null) || (this.espCod != null && !this.espCod.equals(other.espCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "escr.persistencia.Especialidad[espCod=" + espCod + "]";
    }

}
